class Solution
{
public:
    int numPairsDivisibleBy60(vector<int> &time)
    {
        unordered_map<int, int> modCount;
        int result;
        for (int t : time)
        {
            t %= 60;
            result += modCount[(60 - t) % 60];
            ++modCount[t];
        }
        return result;
    }
};